package com.creaylei.stock.controller;

import com.creaylei.stock.dto.ExportQueryDto;
import com.creaylei.stock.po.StockPo;
import com.creaylei.stock.service.WeeklyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author zhang lei
 * @Date 2022-02-28 11:06
 * @Desc 周记统计Controller
 */
@RestController
public class WeeklyReportController {
    @Autowired
    private WeeklyService weeklyService;

    @GetMapping("/api/stock/week/query")
    public List<StockPo> queryNewestInfo(@RequestParam List<String> codes, @RequestParam Double exchangeRate,
                                        @RequestParam("cash") Integer cash) throws IOException {
        return weeklyService.queryNewestInfo(codes, exchangeRate, cash);
    }

    @GetMapping("/api/stock/week/export")
    public void exportNewestInfo(HttpServletResponse response, ExportQueryDto exportQueryDto) {
        weeklyService.export(response, exportQueryDto);
    }
}
